<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<div class="padding-all">
	<c:choose>
		<c:when test="${empty customer}">
			<div class="jumbotron">
			  <h1>Welcome to KSR home!</h1>
			  <p>KSR is the best way to find the learning services for your kids.</p>
			  <p><a class="btn btn-primary btn-lg" role="button" href="/ksr/signup.html">Create Your Free Account</a></p>
			</div>
		</c:when>
		<c:otherwise>
			<c:if test="${not empty interestedOffices}">
				<c:set var="show_max_interested_items" value="2"/>
				<div class="alert alert-success font-16">The services you might be interested...</div>	
				<div class="padding-horizontal">
				<c:forEach items="${interestedOffices}" var="office" varStatus="status">
					<div class="font-16 margin-bottom-half">
						<span>${status.count}.</span>
						<a href="/ksr/office=${office.id}">
						  <c:out value="${office.business.businessName}/${office.address.city }" escapeXml="false" default=""/>
						</a>
					</div>		
				<div class="margin-left rating font-orange font-16">
					<jsp:include page="/WEB-INF/modules/displayStarsByRating.jsp">
						<jsp:param value="${office.rating}" name="rating"/>
					</jsp:include>
					<c:if test="${not empty office.reviewCount}">
						<span class="review-count margin-left-half font-dark">
							<c:out value="${office.reviewCount}"/> 
							<c:choose>
								<c:when test="${office.reviewCount gt 1}">reviews</c:when>
								<c:otherwise>review</c:otherwise>
							</c:choose>
						</span>	
					</c:if>
				</div>
				<div class="full-width font-16">
					<div class="margin-left">
						<label class="bold">Specialty:</label>
						<span class="business-name">
							<c:out value="${office.specialty }" escapeXml="false"/>
						</span>
					</div>												
					<c:if test="${not empty office.address}">
							<address class="margin-left">
									<div class="">
										<i class="icon-location-arrow font-dark"></i>
										<c:out value="${office.address.addressLine1 }"/>
										<c:out value="${office.address.addressLine2}"/>
										<c:out value="${office.address.city}"/>,
										<c:out value="${office.address.state}"/>
										<c:out value="${office.address.zip}"/>
									</div>
							</address>
					</c:if>	
				</div>	
				<c:if test="${not status.last}">
					<div class="separate-row-single"></div>
				</c:if>				
				</c:forEach>
				</div>
			</c:if>
		</c:otherwise>
	</c:choose>
	<c:if test="${not empty recentlyViewedList}">
		<div class="alert alert-info font-16 margin-top">What You've Recently Viewed On KSR</div>
		<c:forEach items="${recentlyViewedList}" var="itemMap" varStatus="status">
			<c:forEach items="${itemMap}" var="entry">
			<c:choose>
				<c:when test="${fn:startsWith(entry.key,'office')}">
					<c:set var="office" value="${entry.value}"/>
					<div class="font-16 margin-bottom-half">
						<span>${status.count}.</span>
						<a href="/ksr/customer/office.html?id=${office.id}">
						  <c:out value="${office.business.businessName}/${office.address.city }" escapeXml="false" default=""/>
						</a>
					</div>		
					<div class="margin-left rating font-orange font-16">
						<jsp:include page="/WEB-INF/modules/displayStarsByRating.jsp">
							<jsp:param value="${office.rating}" name="rating"/>
						</jsp:include>
						<c:if test="${not empty office.reviewCount}">
							<span class="review-count margin-left-half font-dark">
								<c:out value="${office.reviewCount}"/> 
								<c:choose>
									<c:when test="${office.reviewCount gt 1}">reviews</c:when>
									<c:otherwise>review</c:otherwise>
								</c:choose>
							</span>	
						</c:if>
					</div>								
				</c:when>
				<c:when test="${fn:startsWith(entry.key,'reviewer')}">
					<c:set var="reviewer" value="${entry.value}"/>
					<div class="font-16  margin-top">
						<span>${status.count}.</span>
						<a href="/ksr/reviewer.html?id=${reviewer.id}">
						<i class="icon-user icon-large font-lightgrey"></i>
					  		<c:out value="${reviewer.firstName} ${reviewer.lastName }" escapeXml="false" default=""/>'s Profile
					  	</a>
					</div>	
	  				<div class="margin-bottom-half customer-info font-16 ">
	              			<div class="margin-left">
	              				<span class=""><c:out value="${reviewer.address.city}" escapeXml="false" default=""/></span>
	              				<span class=""><c:out value="${reviewer.address.state}" escapeXml="false" default=""/></span>
	              				<%--
	              				<span class=""><c:out value="${fn:length(reviewer.review)}" escapeXml="false" default=""/></span>
	              				<span class="">reviews</span>
	              				 --%>, 
	              			</div>
	              		</div>
				</c:when>
				<c:otherwise>
				</c:otherwise>
			</c:choose>
			</c:forEach>
		</c:forEach>
	</c:if>
</div>
